home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / tool / tpsc16 / src / expan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  2.9 KB  |  130 lines

  1. /*
  2.     線分誇張ユ-ティリティプログラム
  3.      線分を誇張する対象となる色番号は0番
  4.     
  5.     [TPSC16]用外部シェルプログラム
  6.     
  7.     Cre.      1993. 3.20  by Yahara
  8.     Rev.1.0   1993. 3.20  by Yahara
  9. */
  10.  
  11. #define EGBSIZE        1536    // EGB用ワ-クサイズ
  12. #define MOSSIZE        4096    // マウス用ワ-クサイズ
  13. #define BOOL        int        // 論理判断の型宣言
  14. #define TRUE        1        // 真
  15. #define FALSE        0        // 偽
  16. #define MENUPAGE    0        // メニュ-ペ-ジ番号
  17. #define DRAWPAGE    1        // 描画ペ-ジ番号
  18. #define SCREEN        3        // 画面モ-ド
  19. #define DRAWWIDE    640        // 処理画面横サイズ
  20. #define DRAWHIDE    480        // 処理画面縦サイズ
  21.  
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. #include <malloc.h>
  27. #include <math.h>
  28. #include <egb.h>
  29. #include <mos.h>
  30. #include <loader.h>            // コプロセス定義ファイル
  31.  
  32. char EGB_work[EGBSIZE];        // EGBワ-クエリア
  33. char MOS_work[MOSSIZE];        // マウスワ-クエリア
  34.  
  35. char matrix[4][DRAWWIDE];
  36.  
  37. void MatrixInit()
  38. {
  39.     int i,j;
  40.     int col;
  41.     /* 初めの3ライン分のカラ-濃度をマトリックスをセットする */
  42.     for(j=0;j<3;j++) {
  43.         for(i=0;i<DRAWWIDE;i++) {
  44.             EGB_point(EGB_work,0,i,j,&col);
  45.             matrix[j][i] = col;
  46.         }
  47.     }
  48. }
  49.  
  50. void NextMatrixSet(int y)
  51. {
  52.     int i;
  53.     int col;
  54.     /* スキャンするラインの2ライン後をカラ-濃度をセットする */
  55.     for(i=0;i<DRAWWIDE;i++) {
  56.         EGB_point(EGB_work,0,i,y+2,&col);
  57.         matrix[3][i] = col;
  58.     }
  59. }
  60.  
  61. void Pset(int x,int y)
  62. {
  63.     struct {     unsigned short int n;
  64.                 short int x,y; } par;
  65.     /* EGBル-チンの呼び出し */
  66.     par.n = 1;
  67.     par.x = x; par.y = y;
  68.     EGB_pset(EGB_work,(char *)&par);
  69. }
  70.  
  71. void Expansion(int x,int y)
  72. {
  73.     int v1,v2;
  74.     
  75.     /* 画素のチェック */
  76.     if( matrix[1][x] == 0 ) return;
  77.     
  78.     /* 上下左右の濃度を計算 */
  79.     v1 = matrix[0][x] & matrix[1][x-1] & matrix[1][x+1] & matrix[2][x];
  80.     if( v1 > 0 ) {
  81.         /* 4隅の濃度を計算 */
  82.         v2 = matrix[0][x-1] & matrix[0][x+1] & matrix[2][x+1] & matrix[2][x+1];
  83.         if( v2 != 0 ) return;
  84.     }
  85.     /* 点を打つ */
  86.     Pset(x,y);
  87. }
  88.  
  89. void MatrixShift()
  90. {
  91.     /* マトリックバッファをシフトする */
  92.     memmove(&matrix[0][0],&matrix[1][0],DRAWWIDE*3);
  93. }
  94.  
  95. main()
  96. {
  97.     ADDRESS temp;
  98.     int x,y;
  99.     int ch,mx,my;
  100.     
  101.     /* 画面・マウスの初期化 */
  102.     EGB_resolution(EGB_work,MENUPAGE,SCREEN|0x40);        // Page0 Init
  103.     EGB_resolution(EGB_work,DRAWPAGE,SCREEN|0x40);        // Page1 Init
  104.     EGB_displayPage(EGB_work,0,3);                        // 2page view
  105.     MOS_start(MOS_work,MOSSIZE);                        // マウス初期化
  106.     MOS_resolution(MENUPAGE,SCREEN);
  107.     MOS_resolution(DRAWPAGE,SCREEN);
  108.     
  109.     EGB_writePage(EGB_work,DRAWPAGE);    // 描画ペ-ジを指定
  110.     EGB_paintMode(EGB_work,0x22);        // ペイントモ-ドを指定
  111.     EGB_color(EGB_work,0,0);            // ドットの色を指定
  112.     
  113.     /* 処理開始 */
  114.     MatrixInit();
  115.     for(y=1;y<DRAWHIDE-1;y++) {
  116.         MOS_rdpos(&ch,&mx,&my);
  117.         if( ch != 0 ) break;        // マウスが押されたら処理を中断
  118.         NextMatrixSet(y);
  119.         for(x=1;x<DRAWWIDE-1;x++)
  120.             Expansion(x,y);
  121.         MatrixShift();
  122.     }
  123.     
  124.     /* 子プロセスの終了処理 */
  125.     MOS_end();
  126.     pcl_get_dta(&temp);
  127.     pcl_exit(0);
  128.     return (0);
  129. }
  130.